package com.vint.mi;

import java.util.HashMap;
import java.util.Map;

/**
 * Mi Oj 81
 * 同构字符串
 */
public class Mi81 {
    public static String solution(String line){
        String[] src = line.split(",");
        String FALSE_RET = "0";
        String TRUE_RET = "1";
        if(src.length!=2){
            return FALSE_RET;
        }
        String str1 = src[0];
        String str2 = src[1];
        if(str1.length()!=str2.length()){
            return FALSE_RET;
        }
        Map<Character, Character> interAct = new HashMap<Character, Character>();   
        for(int i = 0; i < str1.length();i++){
           if(!interAct.containsKey(str1.charAt(i))){
               interAct.put(str1.charAt(i),str2.charAt(i));
           }else{
               if(interAct.get(str1.charAt(i))!=str2.charAt(i)){
                   return FALSE_RET;
               }
           }
        }
        return TRUE_RET;
    }
    public static void main(String[] args) {
        String example1 = "edd,abb";
        String example2 = "aaa,aba";
        String example3 = "aadefabegegadafbfdacgabfeadge,nnejanrjljlnenaraenulnrajnelj";
        String ret1 = solution(example1);
        String ret2 = solution(example2);
        String ret3 = solution(example3);
        System.out.println(ret1);
        System.out.println(ret2);
        System.out.println(ret3);
    }
}
